package com.yonyou.mybatis.service;

import com.yonyou.mybatis.bean.Employee;
import com.yonyou.mybatis.dao.EmployeeMapper;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import sun.reflect.generics.tree.VoidDescriptor;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@Service
public class EmployeeService {
	
	@Autowired
	private EmployeeMapper employeeMapper;
	
	/*@Autowired
	private SqlSession sqlSession;*/

	@Transactional
	public List<Employee> getEmps(){
		//EmployeeMapper mapper = sqlSession.getMapper(EmployeeMapper.class);
		return employeeMapper.getEmps();
	}

	@Transactional
	public void saveEmployee(HttpServletRequest request){
		Employee employee = new Employee(request.getParameter("lastName"), request.getParameter("email"), 1);
		employeeMapper.saveEmployee(employee);
	}

}
